home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / gate / Gate_ByInetAddr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-05  |  1.7 KB  |  64 lines

  1. /* 
  2.  * Gate_ByInetAddr.c --
  3.  *
  4.  *    Source code for the Gate_ByInetAddr library procedure.
  5.  *
  6.  * Copyright 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /sprite/src/lib/c/gate/RCS/Gate_ByInetAddr.c,v 1.1 92/06/04 22:03:20 jhh Exp $ SPRITE (Berkeley)";
  18. #endif not lint
  19.  
  20. #include <stdio.h>
  21. #include <gate.h>
  22. #include <gateInt.h>
  23.  
  24.  
  25. /*
  26.  *-----------------------------------------------------------------------
  27.  *
  28.  * Gate_ByInetAddr --
  29.  *
  30.  *    Find information about the gateway with the given internet address.
  31.  *
  32.  * Results:
  33.  *    A Gate_Entry structure, or NULL if no gateway exists in the database
  34.  *    with the given internet address.  The Gate_Entry is statically
  35.  *    allocated, and may be modified on the next call to any Gate_
  36.  *    procedure.
  37.  *
  38.  * Side Effects:
  39.  *    The gateway database file is opened if it wasn't already.
  40.  *
  41.  *-----------------------------------------------------------------------
  42.  */
  43.  
  44. Gate_Entry *
  45. Gate_ByInetAddr(inetAddr)
  46.     register Net_InetAddress    inetAddr;    /* Address to match. */
  47. {
  48.     register Gate_Entry            *entry;
  49.  
  50.     if (Gate_Start() == 0 && Net_InetAddrCmp(inetAddr, 0)) {
  51.     while (1) {
  52.         entry = Gate_Next();
  53.         if (entry == (Gate_Entry *) NULL) {
  54.         return (Gate_Entry *) NULL;
  55.         }
  56.         if (!Net_InetAddrCmp(entry->inetAddr, inetAddr)) {
  57.         return (entry);
  58.         }
  59.     }
  60.     }
  61.     return ((Gate_Entry *)NULL);
  62. }
  63.  
  64.